export class IconGroupEntry {
  width: number
  height: number
  colorCount: number = 16
  reserved: number = 0
  planes: number
  bitCount: number
  dwBytesInRes: number
  dwImageOffset: number = 22
  id?: number

  constructor(byteArray: IByteArray) {
    this.width = byteArray.readByte()
    this.height = byteArray.readByte()
    this.colorCount = byteArray.readByte()
    this.reserved = byteArray.readByte()
    this.planes = byteArray.readWord()
    this.bitCount = byteArray.readWord()
    this.dwBytesInRes =byteArray.readDWord()
    this.id = byteArray.readWord()
  }

  public getData(): Uint8Array {
    const dataView = new DataView(new ArrayBuffer(16))
    dataView.setUint8(0, this.width)
    dataView.setUint8(1, this.height)
    dataView.setUint8(2, this.colorCount)
    dataView.setUint8(3, this.reserved)
    dataView.setUint16(4, this.planes, true)
    dataView.setUint16(6, this.bitCount, true)
    dataView.setUint32(8, this.dwBytesInRes, true)
    dataView.setUint32(12, this.dwImageOffset, true)
    return new Uint8Array(dataView.buffer)
  }
}
